package ebook.datastructure.typed.chapter12;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * description: <br>
 * createTime: 2020/9/114:33 <br>
 *
 * @author zzh
 */
//TODO 待完成
public class HeapByLinkedNode<T extends Comparable> implements Heap <T>{
    HeapNode<T> root;
    HeapNode<T> last;


    @Override
    public boolean insert(T t) {
        HeapNode<T> heapNode = new HeapNode<>();
        heapNode.setValue(t);
        if(last == null) {
            root = heapNode;
            last = heapNode;
        } else {
//            last.getParent().get
//            last.getParent() = heapNode;
            trickleUp(last);
        }
        return true;
    }


    private void trickleUp(HeapNode<T> last) {

    }


    @Override
    public T delete() {
        HeapNode<T> result = root;
        return root.getValue();
    }


    @Data
    @NoArgsConstructor
    public class HeapNode <T extends Comparable> {
        T value;
        HeapNode<T> parent;
        HeapNode<T> right;
        HeapNode<T> left;
    }
}
